package com.fenghongzhang.day003;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.RemoteViews;

public class Main4Activity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main4);
    }

    public void dian(View view) {

        Notification.Builder builder = new Notification.Builder(this);
        builder.setSmallIcon(R.mipmap.ic_launcher);
//        builder.setLargeIcon(BitmapFactory.decodeResource(getResources(),R.mipmap.ic_launcher));


        //22
//        builder.setContent(null);

        RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.notify_layout);

        remoteViews.setTextViewText(R.id.huazi,"来个华子");

//        LayoutInflater.from()
        remoteViews.setImageViewResource(R.id.img,R.mipmap.ic_launcher_round);

        //22以上
        builder.setCustomContentView(remoteViews);


        Notification build = builder.build();

        NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

        manager.notify(1,build);

    }

    public void dian2(View view) {

        Notification.Builder builder = new Notification.Builder(this);
        builder.setSmallIcon(R.mipmap.ic_launcher);
//        builder.setLargeIcon(BitmapFactory.decodeResource(getResources(),R.mipmap.ic_launcher));


        //22
//        builder.setContent(null);

        RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.notify_layout);

        remoteViews.setTextViewText(R.id.huazi,"来个华子2");

//        LayoutInflater.from()
        remoteViews.setImageViewResource(R.id.img,R.mipmap.ic_launcher_round);

        //22以上
        builder.setCustomContentView(remoteViews);


        Notification build = builder.build();

        NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

        manager.notify(1,build);
    }
}
